<!doctype html>














<!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="en" 
  
>
  <!-- The Head -->

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="theme-color" media="(prefers-color-scheme: light)" content="#f7f7f7">
  <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1b1b1e">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  <meta
    name="viewport"
    content="width=device-width, user-scalable=no initial-scale=1, shrink-to-fit=no, viewport-fit=cover"
  >

  

  

  
    <!-- Begin Jekyll SEO tag v2.8.0 -->
<meta name="generator" content="Jekyll v4.3.2" />
<meta property="og:title" content="High Performance OS - Intel HPC kernel mOS" />
<meta name="author" content="Chunsheng Luo" />
<meta property="og:locale" content="en" />
<meta name="description" content="一、 简介" />
<meta property="og:description" content="一、 简介" />
<link rel="canonical" href="https://luochenglcs.github.io/posts/Intel-HPC-mOS/" />
<meta property="og:url" content="https://luochenglcs.github.io/posts/Intel-HPC-mOS/" />
<meta property="og:site_name" content="Cheng Luo" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-09-22T00:00:00+00:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="High Performance OS - Intel HPC kernel mOS" />
<meta name="twitter:site" content="@luochenglcs" />
<meta name="twitter:creator" content="@Chunsheng Luo" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Chunsheng Luo","url":"https://github.com/luochenglcs"},"dateModified":"2023-08-07T11:50:53+00:00","datePublished":"2021-09-22T00:00:00+00:00","description":"一、 简介","headline":"High Performance OS - Intel HPC kernel mOS","mainEntityOfPage":{"@type":"WebPage","@id":"https://luochenglcs.github.io/posts/Intel-HPC-mOS/"},"url":"https://luochenglcs.github.io/posts/Intel-HPC-mOS/"}</script>
<!-- End Jekyll SEO tag -->

  

  <title>High Performance OS - Intel HPC kernel mOS | Cheng Luo
  </title>

  <!--
  The Favicons for Web, Android, Microsoft, and iOS (iPhone and iPad) Apps
  Generated by: https://realfavicongenerator.net/
-->



<link rel="apple-touch-icon" sizes="180x180" href="/assets/img/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicons/favicon-16x16.png">
<link rel="manifest" href="/assets/img/favicons/site.webmanifest">
<link rel="shortcut icon" href="/assets/img/favicons/favicon.ico">
<meta name="apple-mobile-web-app-title" content="Cheng Luo">
<meta name="application-name" content="Cheng Luo">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/assets/img/favicons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">


  
    
      <link rel="preconnect" href="https://fonts.googleapis.com" >
      <link rel="dns-prefetch" href="https://fonts.googleapis.com" >
    
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link rel="dns-prefetch" href="https://fonts.gstatic.com" crossorigin>
    
      <link rel="preconnect" href="https://fonts.googleapis.com" >
      <link rel="dns-prefetch" href="https://fonts.googleapis.com" >
    
      <link rel="preconnect" href="https://cdn.jsdelivr.net" >
      <link rel="dns-prefetch" href="https://cdn.jsdelivr.net" >
    

    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lato&family=Source+Sans+Pro:wght@400;600;700;900&display=swap">
  

  <!-- GA -->
  

  <!-- Bootstrap -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">

  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css">

  <link rel="stylesheet" href="/assets/css/style.css">

  
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tocbot@4.21.0/dist/tocbot.min.css">
  

  
    <!-- Manific Popup -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/magnific-popup@1.1.0/dist/magnific-popup.min.css">
  

  <!-- JavaScript -->

  
    <!-- Switch the mode between dark and light. -->

<script type="text/javascript">
  class ModeToggle {
    static get MODE_KEY() {
      return 'mode';
    }
    static get MODE_ATTR() {
      return 'data-mode';
    }
    static get DARK_MODE() {
      return 'dark';
    }
    static get LIGHT_MODE() {
      return 'light';
    }
    static get ID() {
      return 'mode-toggle';
    }

    constructor() {
      if (this.hasMode) {
        if (this.isDarkMode) {
          if (!this.isSysDarkPrefer) {
            this.setDark();
          }
        } else {
          if (this.isSysDarkPrefer) {
            this.setLight();
          }
        }
      }

      let self = this;

      /* always follow the system prefers */
      this.sysDarkPrefers.addEventListener('change', () => {
        if (self.hasMode) {
          if (self.isDarkMode) {
            if (!self.isSysDarkPrefer) {
              self.setDark();
            }
          } else {
            if (self.isSysDarkPrefer) {
              self.setLight();
            }
          }

          self.clearMode();
        }

        self.notify();
      });
    } /* constructor() */

    get sysDarkPrefers() {
      return window.matchMedia('(prefers-color-scheme: dark)');
    }

    get isSysDarkPrefer() {
      return this.sysDarkPrefers.matches;
    }

    get isDarkMode() {
      return this.mode === ModeToggle.DARK_MODE;
    }

    get isLightMode() {
      return this.mode === ModeToggle.LIGHT_MODE;
    }

    get hasMode() {
      return this.mode != null;
    }

    get mode() {
      return sessionStorage.getItem(ModeToggle.MODE_KEY);
    }

    /* get the current mode on screen */
    get modeStatus() {
      if (this.isDarkMode || (!this.hasMode && this.isSysDarkPrefer)) {
        return ModeToggle.DARK_MODE;
      } else {
        return ModeToggle.LIGHT_MODE;
      }
    }

    setDark() {
      document.documentElement.setAttribute(ModeToggle.MODE_ATTR, ModeToggle.DARK_MODE);
      sessionStorage.setItem(ModeToggle.MODE_KEY, ModeToggle.DARK_MODE);
    }

    setLight() {
      document.documentElement.setAttribute(ModeToggle.MODE_ATTR, ModeToggle.LIGHT_MODE);
      sessionStorage.setItem(ModeToggle.MODE_KEY, ModeToggle.LIGHT_MODE);
    }

    clearMode() {
      document.documentElement.removeAttribute(ModeToggle.MODE_ATTR);
      sessionStorage.removeItem(ModeToggle.MODE_KEY);
    }

    /* Notify another plugins that the theme mode has changed */
    notify() {
      window.postMessage(
        {
          direction: ModeToggle.ID,
          message: this.modeStatus
        },
        '*'
      );
    }

    flipMode() {
      if (this.hasMode) {
        if (this.isSysDarkPrefer) {
          if (this.isLightMode) {
            this.clearMode();
          } else {
            this.setLight();
          }
        } else {
          if (this.isDarkMode) {
            this.clearMode();
          } else {
            this.setDark();
          }
        }
      } else {
        if (this.isSysDarkPrefer) {
          this.setLight();
        } else {
          this.setDark();
        }
      }

      this.notify();
    } /* flipMode() */
  } /* ModeToggle */

  const modeToggle = new ModeToggle();
</script>

  

  <!-- A placeholder to allow defining custom metadata -->

</head>


  <body>
    <!-- The Side Bar -->

<div id="sidebar" class="d-flex flex-column align-items-end">
  <div class="profile-wrapper">
    <a href="/" id="avatar" class="rounded-circle">
      
        
        <img src="/assets/img/favicons/android-chrome-512x512.png" width="112" height="112" alt="avatar" onerror="this.style.display='none'">
      
    </a>

    <div class="site-title">
      <a href="/">Cheng Luo</a>
    </div>
    <div class="site-subtitle fst-italic">Linux operating system engineer</div>
  </div>
  <!-- .profile-wrapper -->

  <ul class="nav flex-column flex-grow-1 w-100 ps-0">
    <!-- home -->
    <li class="nav-item">
      <a href="/" class="nav-link">
        <i class="fa-fw fas fa-home"></i>
        <span>HOME</span>
      </a>
    </li>
    <!-- the real tabs -->
    
      <li class="nav-item">
        <a href="/categories/" class="nav-link">
          <i class="fa-fw fas fa-stream"></i>
          

          <span>CATEGORIES</span>
        </a>
      </li>
      <!-- .nav-item -->
    
      <li class="nav-item">
        <a href="/tags/" class="nav-link">
          <i class="fa-fw fas fa-tags"></i>
          

          <span>TAGS</span>
        </a>
      </li>
      <!-- .nav-item -->
    
      <li class="nav-item">
        <a href="/archives/" class="nav-link">
          <i class="fa-fw fas fa-archive"></i>
          

          <span>ARCHIVES</span>
        </a>
      </li>
      <!-- .nav-item -->
    
      <li class="nav-item">
        <a href="/about/" class="nav-link">
          <i class="fa-fw fas fa-info-circle"></i>
          

          <span>ABOUT</span>
        </a>
      </li>
      <!-- .nav-item -->
    
  </ul>
  <!-- ul.nav.flex-column -->

  <div class="sidebar-bottom d-flex flex-wrap  align-items-center w-100">
    
      <button class="mode-toggle btn" aria-label="Switch Mode">
        <i class="fas fa-adjust"></i>
      </button>

      
        <span class="icon-border"></span>
      
    

    
      

      
        <a
          href="https://github.com/luochenglcs"
          aria-label="github"
          

          
            target="_blank"
            
          

          

          
            rel="noopener noreferrer"
          
        >
          <i class="fab fa-github"></i>
        </a>
      
    
      

      
    
      

      
        <a
          href="javascript:location.href = 'mailto:' + ['luochunsheng','ustc.edu'].join('@')"
          aria-label="email"
          

          

          

          
        >
          <i class="fas fa-envelope"></i>
        </a>
      
    
  </div>
  <!-- .sidebar-bottom -->
</div>
<!-- #sidebar -->


    <div id="main-wrapper" class="d-flex justify-content-center">
      <div id="main" class="container px-xxl-5">
        <!-- The Top Bar -->

<div id="topbar-wrapper">
  <div
    id="topbar"
    class="container d-flex align-items-center justify-content-between h-100"
  >
    <span id="breadcrumb">
      

      
        
          
            <span>
              <a href="/">
                Home
              </a>
            </span>

          
        
          
        
          
            
              <span>High Performance OS - Intel HPC kernel mOS</span>
            

          
        
      
    </span>
    <!-- endof #breadcrumb -->

    <i id="sidebar-trigger" class="fas fa-bars fa-fw"></i>

    <div id="topbar-title">
      Post
    </div>

    <i id="search-trigger" class="fas fa-search fa-fw"></i>
    <span id="search-wrapper" class="align-items-center">
      <i class="fas fa-search fa-fw"></i>
      <input
        class="form-control"
        id="search-input"
        type="search"
        aria-label="search"
        autocomplete="off"
        placeholder="Search..."
      >
    </span>
    <span id="search-cancel">Cancel</span>
  </div>
</div>

        











<div class="row">
  <!-- core -->
  <div id="core-wrapper" class="col-12 col-lg-11 col-xl-9 pe-xl-4">
    

    <div class="post px-1 px-md-2">
      

      
        
      
        <!-- Refactor the HTML structure -->



<!--
  In order to allow a wide table to scroll horizontally,
  we suround the markdown table with `<div class="table-wrapper">` and `</div>`
-->



<!--
  Fixed kramdown code highlight rendering:
  https://github.com/penibelst/jekyll-compress-html/issues/101
  https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901
-->



<!-- Change the icon of checkbox -->


<!-- images -->



  
  

  <!-- CDN URL -->
  

  <!-- Add image path -->
  

  
    
      
      
    

    
    

    

    
    

    
    
    
    

    
      

      
      
      

      
    
      

      
      
      

      
    

    <!-- take out classes -->
    

    

    

    

    <!-- lazy-load images <https://github.com/aFarkas/lazysizes#readme> -->
    
    

    <!-- add image placeholder -->
    
      
    

    <!-- Bypass the HTML-proofer test -->
    

    
      <!-- make sure the `<img>` is wrapped by `<a>` -->
      

      
        <!-- create the image wrapper -->
        
      
    

    <!-- combine -->
    

  

  



<!-- Add header for code snippets -->



<!-- Create heading anchors -->





  
  

  

  
  

  
    
    

    
      
        
        
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    

    

  

  
  

  
    
    

    
      
        
        
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    

    

  

  
  

  
    
    

    
      
        
        
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    

    

  




<!-- return -->




<h1 data-toc-skip>High Performance OS - Intel HPC kernel mOS</h1>

<div class="post-meta text-muted">
    <!-- published date -->
    <span>
      Posted
      <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class=""
  data-ts="1632268800"
  data-df="ll"
  
    data-bs-toggle="tooltip" data-bs-placement="bottom"
  
>
  Sep 22, 2021
</em>

    </span>

    <!-- lastmod date -->
    
    <span>
      Updated
      <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class=""
  data-ts="1691409053"
  data-df="ll"
  
    data-bs-toggle="tooltip" data-bs-placement="bottom"
  
>
  Aug  7, 2023
</em>

    </span>
    

  

  <div class="d-flex justify-content-between">
    <!-- author(s) -->
    <span>
      

      By

      <em>
      
        
          <a href="https://github.com/luochenglcs">Chunsheng Luo</a>
          
        
      
      </em>
    </span>

    <div>
      <!-- read time -->
      <!-- Calculate the post's reading time, and display the word count in tooltip -->



<!-- words per minute -->










<!-- return element -->
<span
  class="readtime"
  data-bs-toggle="tooltip"
  data-bs-placement="bottom"
  title="4057 words"
>
  <em>22 min</em> read</span>

    </div>

  </div> <!-- .d-flex -->

</div> <!-- .post-meta -->
<div class="post-content">
  <h3 id="一-简介"><span class="me-2">一、 简介</span><a href="#一-简介" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<p>​	Intel不仅是最大的CPU公司，还是全球最大的软件公司之一，10万员工中有1.5万都是软件工程师。在OS系统上，Intel也开发了多种系统了，现在最新产品是mOS，一款专用于HPC超算的高性能Linux变种。Intel的mOS系统很少人关注，官方透露的细节也不多，目前还在开发中，主要用于高性能计算，在超算负载中可以提供更好的并行性及可靠性。</p>

<p>​	mOS系统依然会基于Linux扩展而来，目前最新版0.8版使用的是Linux 5.4 LTS内核，但它又有自己的LWK轻量级内核，Linux内核管理少量部分CPU核心，以确保兼容性，LWK内核管理系统其他部分，类似Mutil-OS多OS。</p>

<p>​	Intel的mOS已经在ASCI Red，IBM Blue Gene等超算上应用，不过它最终的目标是用于2021年的百亿亿次超算Aurora上，后者采用了未来一代的Intel至强可扩展处理器、Intel Xe计算架构、Intel未来一代的傲腾DC可持续内存、Intel One API软件等。</p>

<p>该超算同时采用Cray的新一代超算平台“Shasta”，由超过200个机柜组成，支持Cray Slingshot高性能可扩展互连架构，并在软件堆栈方面针对Intel架构进行专门优化。</p>

<h3 id="二mos内存管理"><span class="me-2">二、mOS内存管理</span><a href="#二mos内存管理" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="rouge-code"><pre><span class="mi">1</span><span class="err">：什么是</span><span class="n">Mos</span>
<span class="n">Mos</span><span class="err">是一款</span><span class="n">intel</span> <span class="err">开发的，针对</span><span class="n">HPC</span><span class="err">场景优化的</span><span class="n">os</span><span class="err">，目前已经开源，其开源网址为</span><span class="n">https</span><span class="o">:</span><span class="c1">//github.com/intel/mOS。</span>
 <span class="mi">2</span><span class="err">：</span><span class="n">Mos</span><span class="err">和</span><span class="n">linux</span> <span class="n">kernel</span><span class="err">的区别。</span>
<span class="n">Mos</span> <span class="err">是在</span><span class="n">linux</span> <span class="n">kernel</span><span class="err">的根目录下面加了一个</span><span class="n">mos</span><span class="err">的文件夹，里面放的是</span><span class="n">Mos</span><span class="err">的主要文件，总结一下，</span><span class="n">Mos</span><span class="err">就是内嵌到</span><span class="n">linux</span> <span class="n">kernel</span><span class="err">中的一个轻量级</span><span class="n">os</span><span class="p">.</span>
 <span class="mi">3</span><span class="o">:</span> <span class="n">Mos</span> <span class="err">的工作原理</span>
 <span class="err">通过命令行参数</span> <span class="n">lwkcpus</span> <span class="err">和</span><span class="n">lwkmem</span> <span class="err">来隔离内存和</span><span class="n">cpu</span><span class="err">，或则通过</span><span class="n">lwkctl</span> <span class="err">来在</span><span class="n">linux</span> <span class="n">kernel</span><span class="err">启动后来隔离</span><span class="n">cpu</span><span class="err">和内存。</span>
<span class="err">其中</span><span class="n">lwkcpus</span><span class="err">的使用举例如下</span>
 <span class="n">lwkcpus</span><span class="o">=&lt;</span><span class="n">syscall</span> <span class="n">cpu1</span><span class="o">&gt;</span><span class="p">.</span><span class="o">&lt;</span><span class="n">lwkcpu</span> <span class="n">set1</span><span class="o">&gt;:&lt;</span><span class="n">syscall</span> <span class="n">cpu2</span><span class="o">&gt;</span><span class="p">.</span><span class="o">&lt;</span><span class="n">lwkcpu</span> <span class="n">set2</span><span class="o">&gt;</span><span class="p">...</span>
 <span class="n">For</span> <span class="n">example</span><span class="o">:</span>
 <span class="n">lwkcpus</span><span class="o">=</span><span class="mi">28</span><span class="p">.</span><span class="mi">1</span><span class="o">-</span><span class="mi">13</span><span class="p">,</span><span class="mi">29</span><span class="o">-</span><span class="mi">41</span><span class="o">:</span><span class="mi">42</span><span class="p">.</span><span class="mi">15</span><span class="o">-</span><span class="mi">27</span><span class="p">,</span><span class="mi">43</span><span class="o">-</span><span class="mi">55</span>
 <span class="n">https</span><span class="o">:</span><span class="c1">//github.com/intel/mOS/wiki/mOS-for-HPC-v0.8-Administrator's-Guide</span>
<span class="n">The</span> <span class="n">following</span> <span class="n">parameters</span> <span class="n">and</span> <span class="n">values</span> <span class="n">are</span> <span class="n">recommended</span> <span class="k">for</span> <span class="n">mOS</span> <span class="k">for</span> <span class="n">HPC</span><span class="p">.</span>  <span class="n">Not</span> <span class="n">all</span> <span class="n">combinations</span> <span class="n">and</span> <span class="n">variations</span> <span class="n">of</span> <span class="n">boot</span> <span class="n">parameters</span> <span class="n">have</span> <span class="n">been</span> <span class="n">validated</span> <span class="n">and</span> <span class="n">tested</span><span class="p">.</span>  <span class="n">Boot</span> <span class="n">failure</span> <span class="n">is</span> <span class="n">possible</span> <span class="k">if</span><span class="p">,</span> <span class="k">for</span> <span class="n">example</span><span class="p">,</span> <span class="n">lwkcpus</span> <span class="n">and</span> <span class="n">lwkmem</span> <span class="n">are</span> <span class="n">not</span> <span class="n">properly</span> <span class="n">set</span> <span class="k">for</span> <span class="n">your</span> <span class="n">system</span><span class="p">.</span> <span class="n">The</span> <span class="n">lwkcpus</span> <span class="n">and</span> <span class="n">lwkmem</span> <span class="n">parameters</span> <span class="n">can</span> <span class="n">be</span> <span class="n">omitted</span> <span class="n">and</span> <span class="n">the</span> <span class="n">lightweight</span> <span class="n">kernel</span> <span class="n">partition</span> <span class="n">created</span> <span class="n">after</span> <span class="n">booting</span> <span class="n">using</span> <span class="n">the</span> <span class="n">lwkctl</span> <span class="n">command</span><span class="p">.</span> <span class="n">Please</span> <span class="n">refer</span> <span class="n">to</span> <span class="n">Documentation</span><span class="o">/</span><span class="n">kernel</span><span class="o">-</span><span class="n">parameters</span><span class="p">.</span><span class="n">txt</span> <span class="n">in</span> <span class="n">the</span> <span class="n">mOS</span> <span class="k">for</span> <span class="n">HPC</span> <span class="n">kernel</span> <span class="n">source</span> <span class="k">for</span> <span class="n">further</span> <span class="n">details</span><span class="p">.</span>
<span class="mi">4</span><span class="o">:</span><span class="err">应用怎么运行到</span><span class="n">Mos</span><span class="err">上</span>
<span class="err">正常不加任何前缀的话，应用运行在</span><span class="n">linux</span> <span class="n">kernel</span><span class="err">上，加</span><span class="n">yod</span><span class="err">的话，应用运行在</span><span class="n">Mos</span><span class="err">中</span>
<span class="n">https</span><span class="o">:</span><span class="c1">//github.com/intel/mOS/wiki/mOS-for-HPC-v0.8-User's-Guide</span>
 <span class="n">The</span> <span class="n">yod</span> <span class="n">utility</span> <span class="n">of</span> <span class="n">mOS</span> <span class="n">is</span> <span class="n">the</span> <span class="n">fundamental</span> <span class="n">mechanism</span> <span class="k">for</span> <span class="n">spawning</span> <span class="n">LWK</span> <span class="n">processes</span><span class="p">.</span>  <span class="n">The</span> <span class="n">syntax</span> <span class="n">is</span><span class="o">:</span>
 <span class="n">yod</span> <span class="n">yod</span><span class="o">-</span><span class="n">arguments</span> <span class="n">program</span> <span class="n">program</span><span class="o">-</span><span class="n">arguments</span>
 <span class="mi">5</span><span class="err">：</span><span class="n">linux</span> <span class="n">kernel</span> <span class="err">和</span><span class="n">Mos</span><span class="err">的关系</span>
<span class="err">————————————————</span>
<span class="err">版权声明：本文为</span><span class="n">CSDN</span><span class="err">博主「</span><span class="n">tiantao2012</span><span class="err">」的原创文章，遵循</span><span class="n">CC</span> <span class="mi">4</span><span class="p">.</span><span class="mi">0</span> <span class="n">BY</span><span class="o">-</span><span class="n">SA</span><span class="err">版权协议，转载请附上原文出处链接及本声明。</span>
<span class="err">原文链接：</span><span class="n">https</span><span class="o">:</span><span class="c1">//blog.csdn.net/tiantao2012/article/details/113852469</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="n">lwkcpu</span><span class="o">=</span><span class="mi">8</span><span class="p">.</span><span class="mi">9</span><span class="o">-</span><span class="mi">15</span> <span class="n">lwkmem</span><span class="o">=</span><span class="mi">0</span><span class="o">:</span><span class="mi">128</span><span class="n">G</span><span class="p">,</span><span class="mi">1</span><span class="o">:</span><span class="mi">128</span><span class="n">G</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
</pre></td><td class="rouge-code"><pre><span class="n">lwk_config_lwkmem</span> <span class="c1">//入参为NULL,destroy mem;反之create.</span>
    <span class="o">-&gt;</span><span class="k">if</span> <span class="n">param_value</span> <span class="o">==</span> <span class="nb">NULL</span> <span class="o">?</span> <span class="n">lwkmem_partition_destroy</span> <span class="o">:</span> <span class="n">lwkmem_partition_create</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="1lwkmem_partition_create创建lwkmem-partition"><span class="me-2">1、lwkmem_partition_create创建lwkmem partition</span><a href="#1lwkmem_partition_create创建lwkmem-partition" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="rouge-code"><pre><span class="cp">#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store)
</span><span class="k">static</span> <span class="k">struct</span> <span class="n">kobj_attribute</span> <span class="n">lwk_config_attr</span> <span class="o">=</span> <span class="n">__ATTR_RW</span><span class="p">(</span><span class="n">lwk_config</span><span class="p">);</span>
<span class="o">-&gt;</span><span class="n">lwk_config_store</span> <span class="n">lwk_config_show</span>
<span class="c1">///strcmp(s_keyword, "lwkmem")</span>
<span class="n">lwk_config_store</span>
    <span class="o">-&gt;</span><span class="n">lwk_config_lwkmem</span>
    
  <span class="c1">//系统启动</span>
<span class="n">rest_init</span>
	<span class="o">-&gt;</span><span class="n">kernel_init</span> <span class="c1">//在free_initmem之后</span>
		<span class="o">-&gt;</span><span class="n">lwkctl_def_partition</span>
    		<span class="o">-&gt;</span><span class="n">lwk_config_lwkmem</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
</pre></td><td class="rouge-code"><pre><span class="n">lwkmem_partition_create</span>
    <span class="o">-&gt;</span><span class="n">lwkmem_parse_args</span> <span class="c1">//spec参数，解析mos_lwkmem_nodes, mos_lwkmem_size信息.</span>
    <span class="o">-&gt;</span><span class="n">mos_mem_init</span>
</pre></td></tr></tbody></table></code></div></div>

<h5 id="1mos_mem_init初始化内存"><span class="me-2">1)mos_mem_init初始化内存</span><a href="#1mos_mem_init初始化内存" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h5>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="rouge-code"><pre><span class="n">mos_mem_init</span>
    <span class="o">-&gt;</span><span class="n">for_each_node_mask</span>  <span class="n">allocate_memory_from_linux</span><span class="p">(</span><span class="n">nid</span><span class="p">,</span> <span class="n">req_size</span><span class="p">)</span>
    <span class="c1">//申请的nid上内存记录在static struct lwkmem_designated lwkmem[MAX_NUMNODES];中</span>
    <span class="cm">/*
 * lwkmem[MAX_NUMNODES],
 *   Used to track all the physical memory ranges designated to LWK.
 *   An element at index N gives the lwkmem_designated structure that
 *   embeds the list head for all designated memory granules and
 *   keeps the counters that indicate number of free and available
 *   memory in terms of pages on that NUMA node.
 *              
 *   lwkmem[NID]           lwkmem_granule         lwkmem_granule
 *   +--------------+      +-----------------+    +-----------------+
 *   | list         |-----&gt;| list_designated |---&gt;| list_designated |
 *   | n_resv_pages |      | list_reserved   |    | list_reserved   |
 *   | n_free_pages |      | base            |    | base            |
 *   +--------------+      | length          |    | length          |
 *                         | owner           |    | owner           |
 *                         +-----------------+    +-----------------+
 */</span> 
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="rouge-code"><pre><span class="c1">//mOS/lwkmem/pma_buddy.c</span>
<span class="k">static</span> <span class="k">struct</span> <span class="n">lwk_pm_factory_operations</span> <span class="n">pma_buddy_factory_ops</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">alloc_pma</span> <span class="o">=</span> <span class="n">alloc_pma_buddy</span><span class="p">,</span>
        <span class="p">.</span><span class="n">free_pma</span> <span class="o">=</span> <span class="n">free_pma_buddy</span>
<span class="p">};</span>
<span class="k">static</span> <span class="k">struct</span> <span class="n">lwk_pm_operations</span> <span class="n">pma_buddy_ops</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">alloc_pages</span> <span class="o">=</span> <span class="n">buddy_alloc_pages</span><span class="p">,</span>
        <span class="p">.</span><span class="n">free_pages</span> <span class="o">=</span> <span class="n">buddy_free_pages</span><span class="p">,</span>
        <span class="p">.</span><span class="n">split_page</span> <span class="o">=</span> <span class="n">buddy_split_page</span><span class="p">,</span>
        <span class="p">.</span><span class="n">report</span> <span class="o">=</span> <span class="n">buddy_report</span><span class="p">,</span>
        <span class="p">.</span><span class="n">meminfo</span> <span class="o">=</span> <span class="n">buddy_meminfo</span><span class="p">,</span>
        <span class="p">.</span><span class="n">setup</span> <span class="o">=</span> <span class="n">buddy_setup</span>
<span class="p">};</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
</pre></td><td class="rouge-code"><pre><span class="c1">//注册pma操作，申请、释放、拆分、报告、统计、setup</span>
<span class="n">pma_buddy_init</span>
    <span class="o">-&gt;</span><span class="n">register_lwk_pma</span>  <span class="c1">//pm_registered_ops</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="rouge-code"><pre><span class="n">lwkmem_early_init</span>
	<span class="o">-&gt;</span><span class="n">mos_register_process_callbacks</span> <span class="c1">//mos_process_callbacks</span>

<span class="c1">//lwkmem_callbacks回调来执行lwkmem_process_start申请lwkmem</span>
<span class="k">static</span> <span class="k">struct</span> <span class="n">mos_process_callbacks_t</span> <span class="n">lwkmem_callbacks</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">mos_process_init</span> <span class="o">=</span> <span class="n">lwkmem_process_init</span><span class="p">,</span>
        <span class="p">.</span><span class="n">mos_process_start</span> <span class="o">=</span> <span class="n">lwkmem_process_start</span><span class="p">,</span>
        <span class="p">.</span><span class="n">mos_process_exit</span> <span class="o">=</span> <span class="n">lwkmem_process_exit</span><span class="p">,</span>
<span class="p">};</span>  

<span class="n">lwkmem_process_start</span>
    <span class="o">-&gt;</span><span class="n">start_lwk_mm</span>
        <span class="o">-&gt;|</span> <span class="n">curr_lwk_mm</span>
        <span class="o">-&gt;|</span> <span class="n">lwk_mm_set_mempolicy_info</span>
        <span class="o">-&gt;|</span> <span class="p">[</span><span class="n">Assigning</span> <span class="n">Values</span><span class="p">]</span> <span class="c1">//lwk_mm-&gt;pma = pma_buddy_factory_ops-&gt;alloc_pma; lwk_mm-&gt;pm_ops = pma_buddy_ops</span>
        <span class="o">-&gt;|</span> <span class="n">pma_buddy_ops</span><span class="o">-&gt;</span><span class="n">setup</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
</pre></td><td class="rouge-code"><pre><span class="n">MOS_SYSFS_CPU_WO</span><span class="p">(</span><span class="n">lwkcpus_request</span><span class="p">);</span>
<span class="k">static</span> <span class="k">struct</span> <span class="n">mos_sysfs_mask_write_op</span> <span class="n">name</span><span class="err">##</span><span class="n">_mask_op</span> <span class="o">=</span> <span class="p">{</span>        \
    <span class="p">.</span><span class="n">parser</span> <span class="o">=</span> <span class="n">cpumask_parse</span><span class="p">,</span>                                \
    <span class="p">.</span><span class="n">operation</span> <span class="o">=</span> <span class="n">_</span><span class="err">##</span><span class="n">name</span><span class="err">##</span><span class="n">_set</span><span class="p">,</span>                             <span class="err">\</span> <span class="c1">///here</span>
<span class="p">};</span>  
<span class="n">_lwkcpus_request_set</span>
	<span class="o">-&gt;</span><span class="n">mos_get_process</span> <span class="c1">//给进程设置mos_process  current-&gt;mos_process</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="rouge-code"><pre><span class="k">static</span> <span class="k">struct</span> <span class="n">kobj_attribute</span> <span class="n">lwkmem_request_attr</span> <span class="o">=</span> <span class="n">__ATTR_WO</span><span class="p">(</span><span class="n">lwkmem_request</span><span class="p">);</span>
<span class="n">lwkmem_request_store</span>
    <span class="o">-&gt;</span><span class="n">lwkmem_request</span>
        <span class="o">-&gt;</span><span class="n">allocate_lwk_mm</span> <span class="c1">//lwk_mm-&gt;vm_ops = &amp;lwk_vm_ops;</span>
            <span class="o">-&gt;</span><span class="n">set_lwk_mm</span> <span class="c1">//设置给进程</span>
    
<span class="c1">//mOS/lwkmem/mm.c</span>
<span class="k">static</span> <span class="k">struct</span> <span class="n">lwk_vm_operations</span> <span class="n">lwk_vm_ops</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">get_unmapped_area</span>      <span class="o">=</span> <span class="n">lwk_mm_get_unmapped_area</span><span class="p">,</span>
        <span class="p">.</span><span class="n">unmap_page_range</span>       <span class="o">=</span> <span class="n">lwk_mm_unmap_pages</span><span class="p">,</span>
        <span class="p">.</span><span class="n">move_page_tables</span>       <span class="o">=</span> <span class="n">lwk_mm_move_page_tables</span><span class="p">,</span>
        <span class="p">.</span><span class="n">change_protection</span>      <span class="o">=</span> <span class="n">lwk_mm_change_protection</span><span class="p">,</span>
        <span class="p">.</span><span class="n">follow_page</span>            <span class="o">=</span> <span class="n">lwk_mm_follow_page</span><span class="p">,</span>
        <span class="p">.</span><span class="n">page_fault</span>             <span class="o">=</span> <span class="n">lwk_mm_page_fault</span><span class="p">,</span>
        <span class="p">.</span><span class="n">alloc_pages_vma</span>        <span class="o">=</span> <span class="n">lwk_mm_alloc_pages_vma</span><span class="p">,</span>
        <span class="p">.</span><span class="n">vma_adjust</span>             <span class="o">=</span> <span class="n">lwk_mm_vma_adjust</span><span class="p">,</span>
        <span class="p">.</span><span class="n">populated</span>              <span class="o">=</span> <span class="n">lwk_mm_vma_populated</span><span class="p">,</span>
        <span class="p">.</span><span class="n">fork</span>                   <span class="o">=</span> <span class="n">lwk_mm_fork</span><span class="p">,</span>
        <span class="p">.</span><span class="n">clear_heap</span>             <span class="o">=</span> <span class="n">lwk_mm_clear_heap</span><span class="p">,</span>
        <span class="p">.</span><span class="n">elf_map</span>                <span class="o">=</span> <span class="n">lwk_mm_elf_map</span><span class="p">,</span>
<span class="p">};</span>

<span class="c1">//include/linux/moslwkmem.h</span>
<span class="cp">#define lwkmem_get_unmapped_area_ops() \
                curr_lwk_mm()-&gt;vm_ops-&gt;get_unmapped_area
#define lwkmem_page_fault(vma, addr, flags)\
                vma_lwk_mm(vma)-&gt;vm_ops-&gt;page_fault(vma, addr, flags)
#define lwkmem_unmap_range(vma, start, end)\
                vma_lwk_mm(vma)-&gt;vm_ops-&gt;unmap_page_range(vma, start, end)
#define lwkmem_change_protection_range(vma, start, end, prot) \
                vma_lwk_mm(vma)-&gt;vm_ops-&gt;change_protection(vma, start, end, \
                                                           prot)
#define lwkmem_vma_adjust(vma, start, end) \
                vma_lwk_mm(vma)-&gt;vm_ops-&gt;vma_adjust(vma, start, end)
#define lwkmem_follow_page(vma, addr, flags, pagemask) \
                vma_lwk_mm(vma)-&gt;vm_ops-&gt;follow_page(vma, addr, flags, pagemask)
#define lwkmem_move_page_tables(old_vma, old_addr, new_vma, new_addr, len) \
                vma_lwk_mm(old_vma)-&gt;vm_ops-&gt;move_page_tables(old_vma, \
                                                old_addr, new_vma, new_addr,\
                                                len)
#define lwkmem_populated(vma) \
                vma_lwk_mm(vma)-&gt;vm_ops-&gt;populated(vma)
#define lwkmem_fork(oldvma, newvma) \
                vma_lwk_mm(oldvma)-&gt;vm_ops-&gt;fork(oldvma, newvma)
#define lwkmem_clear_heap(vma, oldbrk, newbrk) \
                vma_lwk_mm(vma)-&gt;vm_ops-&gt;clear_heap(vma, oldbrk, newbrk)
#define lwkmem_elf_map(s, len, fp, off, addr, sz, tsz) \
                curr_lwk_mm()-&gt;vm_ops-&gt;elf_map(s, len, fp, off, addr, sz, tsz)
</span></pre></td></tr></tbody></table></code></div></div>

<h4 id="2lwkmem_partition_destroy销毁lwkmem-partition"><span class="me-2">2、lwkmem_partition_destroy销毁lwkmem partition</span><a href="#2lwkmem_partition_destroy销毁lwkmem-partition" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<h3 id="三how-use-yod"><span class="me-2">三、how use? yod</span><a href="#三how-use-yod" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<h4 id="问题2-syscall-cpu1utility_cpus-怎么使用处理syscall-什么意思"><span class="me-2">问题2： syscall cpu1/utility_cpus 怎么使用，处理syscall 什么意思？</span><a href="#问题2-syscall-cpu1utility_cpus-怎么使用处理syscall-什么意思" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
</pre></td><td class="rouge-code"><pre><span class="n">syscall</span> <span class="err">指令：</span>
<span class="n">https</span><span class="o">:</span><span class="c1">//man7.org/linux/man-pages/man2/syscall.2.html</span>
<span class="n">syscall</span><span class="err">调用流程：</span>
<span class="n">http</span><span class="o">:</span><span class="c1">//gityuan.com/2016/05/21/syscall/</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
</pre></td><td class="rouge-code"><pre><span class="c1">//mOS/mos.c</span>
<span class="n">yod</span> <span class="o">-&gt;</span> <span class="err">调用</span><span class="n">sysfs</span><span class="err">接口</span>
<span class="n">_lwkcpus_request_set</span>
	<span class="nf">cpumask_or</span><span class="p">(</span><span class="n">current</span><span class="o">-&gt;</span><span class="n">mos_process</span><span class="o">-&gt;</span><span class="n">utilcpus</span><span class="p">,</span> <span class="n">current</span><span class="o">-&gt;</span><span class="n">mos_process</span><span class="o">-&gt;</span><span class="n">utilcpus</span><span class="p">,</span> <span class="n">utility_cpus_map</span><span class="p">);</span> <span class="c1">//utilcpus</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="rouge-code"><pre><span class="nl">copy_process:</span><span class="mi">2087</span> 
<span class="err">这个写的也太详细了：</span> <span class="n">http</span><span class="o">:</span><span class="c1">//gityuan.com/2017/08/05/linux-process-fork/</span>
<span class="n">sched_fork</span> <span class="o">-&gt;</span> <span class="p">.</span><span class="n">task_fork</span>
<span class="c1">//.task_fork              = task_fork_mos,</span>
<span class="c1">// Called on fork with the child task as argument from the parent's context</span>
<span class="c1">//- child not yet on the tasklist</span>
<span class="c1">//- preemption disabled</span>
<span class="n">task_fork_mos</span>
    <span class="o">-&gt;|</span><span class="n">push_utility_threads</span>
        <span class="o">-&gt;||</span><span class="n">select_linux_utility_cpus</span> <span class="c1">//选择utility_cpus的CPU</span>
        <span class="o">-&gt;||</span><span class="n">push_to_linux_scheduler</span> <span class="c1">//push到linux调度域？</span>
    <span class="o">-&gt;|</span><span class="n">set_utility_cpus_allowed</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="问题3-lwkcpu的调度是个简化版具体原理"><span class="me-2">问题3： lwkcpu的调度是个简化版，具体原理？</span><a href="#问题3-lwkcpu的调度是个简化版具体原理" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
</pre></td><td class="rouge-code"><pre><span class="nl">http:</span><span class="c1">//www.wowotech.net/process_management/447.html //调度类实现</span>
<span class="n">https</span><span class="o">:</span><span class="c1">//linuxtoy.org/archives/bfs-intro-future-of-linux-desktop-kernel.html 脑残调度器</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
</pre></td><td class="rouge-code"><pre><span class="n">CPU</span><span class="err">拓扑结构存在下面三个</span><span class="n">level</span><span class="err">（</span><span class="n">SMT</span> <span class="n">level</span><span class="err">最低）：</span>
<span class="n">SMT</span> <span class="n">Level</span> <span class="err">超线程处理器的一个核心</span>
<span class="n">MC</span> <span class="n">Level</span> <span class="err">多核</span><span class="n">CPU</span><span class="err">的一个核心</span>
<span class="n">DIE</span> <span class="n">Level</span> <span class="err">一个物理</span><span class="n">CPU</span><span class="err">的晶片（注意不是</span><span class="n">package</span><span class="err">，</span><span class="n">package</span><span class="err">是封装好了的，肉眼看到的</span><span class="n">CPU</span><span class="err">处理器）</span>
<span class="n">cpu</span><span class="err">最小级别的就是超线程处理器的一个</span><span class="n">smt</span><span class="err">核，次小的一级就是一个多核</span><span class="n">cpu</span><span class="err">的核，然后就是一个物理</span><span class="n">cpu</span><span class="err">封装，再往后就是</span><span class="n">cpu</span><span class="err">阵列，根据这些</span><span class="n">cpu</span><span class="err">级别的不同，</span><span class="n">Linux</span><span class="err">将所有同一级别的</span><span class="n">cpu</span><span class="err">归为一个“调度组”，然后将同一级别的所有的调度组组成一个“调度域”</span><span class="n">cpu</span><span class="err">最小级别的就是超线程处理器的一个</span><span class="n">smt</span><span class="err">核，次小的一级就是一个多核</span><span class="n">cpu</span><span class="err">的核，然后就是一个物理</span><span class="n">cpu</span><span class="err">封装，再往后就是</span><span class="n">cpu</span><span class="err">阵列，根据这些</span><span class="n">cpu</span><span class="err">级别的不同，</span><span class="n">Linux</span><span class="err">将所有同一级别的</span><span class="n">cpu</span><span class="err">归为一个“调度组”，然后将同一级别的所有的调度组组成一个“调度域”</span>
<span class="err">对于</span><span class="n">ARM</span> <span class="err">架构，目前由于不支持超线程技术，只有</span><span class="n">DIE</span><span class="err">和</span><span class="n">MC</span><span class="err">两个</span><span class="n">Topology</span> <span class="n">Level</span>
<span class="err">————————————————</span>
<span class="err">原文链接：</span><span class="n">https</span><span class="o">:</span><span class="c1">//blog.csdn.net/wukongmingjing/article/details/81664820 调度域和调度组</span>
</pre></td></tr></tbody></table></code></div></div>

<p><a href="/posts/.\images\Intel-HPC-mOS\DIE-MC-SMT.png" class="popup img-link "><img data-src="/posts/.\images\Intel-HPC-mOS\DIE-MC-SMT.png" alt="image-20210922110532845" class="lazyload" data-proofer-ignore></a></p>

<pre><code class="language-C">  16  *  kernel/sched/mos.c
  17  *
  18  * When executing on a CPU that has been designated to be an LWK CPU, all tasks
  19  * are managed by the mOS scheduler. However, the tasks within the mOS
  20  * scheduler must occasionally interact with the Linux scheduler. For
  21  * example, a Linux/mOS task may be blocked on a mutex held by a mOS/Linux task
  22  * and will need to be awakened when the resource is released. Also when an
  23  * mOS process is executing on an Linux core due to evanescence, this task must
  24  * obey the rules of the linux scheduler. This file contains the mOS scheduler
  25  * and the mos scheduler class that allow the the two schedulers to
  26  * interoperate.
      在指定为LWK CPU的CPU上执行时，所有任务都由mOS调度程序管理。但是，mOS调度程序中的任务偶
      尔必须与Linux调度程序交互。例如，Linux/mOS任务可能会在mOS/Linux任务持有的互斥体上被阻
      止，并且需要在释放资源时唤醒。此外，当mOS进程因消失而在Linux核心上执行时，此任务必须遵
      守linux调度程序的规则。此文件包含允许两个调度程序互操作的mOS调度程序和mos调度程序类。
</code></pre>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="rouge-code"><pre><span class="k">const</span> <span class="k">struct</span> <span class="n">sched_class</span> <span class="n">mos_sched_class</span> 
        <span class="n">__attribute__</span><span class="p">((</span><span class="n">section</span><span class="p">(</span><span class="s">"__mos_sched_class"</span><span class="p">)))</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">enqueue_task</span>           <span class="o">=</span> <span class="n">enqueue_task_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">dequeue_task</span>           <span class="o">=</span> <span class="n">dequeue_task_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">yield_task</span>             <span class="o">=</span> <span class="n">yield_task_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">check_preempt_curr</span>     <span class="o">=</span> <span class="n">check_preempt_curr_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">pick_next_task</span>         <span class="o">=</span> <span class="n">pick_next_task_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">put_prev_task</span>          <span class="o">=</span> <span class="n">put_prev_task_mos</span><span class="p">,</span>

<span class="cp">#ifdef CONFIG_SMP
</span>        <span class="p">.</span><span class="n">balance</span>                <span class="o">=</span> <span class="n">balance_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">select_task_rq</span>         <span class="o">=</span> <span class="n">select_task_rq_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">set_cpus_allowed</span>       <span class="o">=</span> <span class="n">set_cpus_allowed_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">rq_online</span>              <span class="o">=</span> <span class="n">rq_online_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">rq_offline</span>             <span class="o">=</span> <span class="n">rq_offline_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">task_woken</span>             <span class="o">=</span> <span class="n">task_woken_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">switched_from</span>          <span class="o">=</span> <span class="n">switched_from_mos</span><span class="p">,</span>
<span class="cp">#endif
</span>        <span class="p">.</span><span class="n">set_next_task</span>          <span class="o">=</span> <span class="n">set_next_task_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">task_tick</span>              <span class="o">=</span> <span class="n">task_tick_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_rr_interval</span>        <span class="o">=</span> <span class="n">get_rr_interval_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">prio_changed</span>           <span class="o">=</span> <span class="n">prio_changed_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">switched_to</span>            <span class="o">=</span> <span class="n">switched_to_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">update_curr</span>            <span class="o">=</span> <span class="n">update_curr_mos</span><span class="p">,</span>
        <span class="p">.</span><span class="n">task_fork</span>              <span class="o">=</span> <span class="n">task_fork_mos</span><span class="p">,</span>
<span class="p">};</span>    
</pre></td></tr></tbody></table></code></div></div>

<h5 id="抓个lwkcpu的调度轨迹"><span class="me-2">抓个lwkcpu的调度轨迹？</span><a href="#抓个lwkcpu的调度轨迹" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h5>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="rouge-code"><pre><span class="k">static</span> <span class="k">struct</span> <span class="n">mos_process_callbacks_t</span> <span class="n">lwksched_callbacks</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">mos_process_init</span> <span class="o">=</span> <span class="n">lwksched_process_init</span><span class="p">,</span>
        <span class="p">.</span><span class="n">mos_process_start</span> <span class="o">=</span> <span class="n">lwksched_process_start</span><span class="p">,</span>
        <span class="p">.</span><span class="n">mos_thread_exit</span> <span class="o">=</span> <span class="n">lwksched_thread_exit</span><span class="p">,</span>
        <span class="p">.</span><span class="n">mos_process_exit</span> <span class="o">=</span> <span class="n">lwksched_process_exit</span><span class="p">,</span>
<span class="p">};</span>

<span class="n">lwksched_mod_init</span>
    <span class="o">-&gt;|</span><span class="n">mos_register_process_callbacks</span> <span class="n">lwksched_callbacks</span>
    
    
<span class="k">static</span> <span class="k">struct</span> <span class="n">mos_process_callbacks_t</span> <span class="n">lwkmem_callbacks</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">mos_process_init</span> <span class="o">=</span> <span class="n">lwkmem_process_init</span><span class="p">,</span>
        <span class="p">.</span><span class="n">mos_process_start</span> <span class="o">=</span> <span class="n">lwkmem_process_start</span><span class="p">,</span>
        <span class="p">.</span><span class="n">mos_process_exit</span> <span class="o">=</span> <span class="n">lwkmem_process_exit</span><span class="p">,</span>
<span class="p">};</span> 

<span class="n">subsys_initcall</span> <span class="n">lwkmem_early_init</span>
    <span class="o">-&gt;</span><span class="n">mos_register_process_callbacks</span> <span class="n">lwkmem_callbacks</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="定论1lwkcpu只能一个program使用"><span class="me-2">定论1：lwkcpu只能一个program使用</span><a href="#定论1lwkcpu只能一个program使用" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="rouge-code"><pre><span class="c1">//mOS/tools/yod/mos_plugin.c</span>
<span class="k">struct</span> <span class="n">yod_plugin</span> <span class="n">mos_plugin</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">.</span><span class="n">get_designated_lwkcpus</span> <span class="o">=</span> <span class="n">mos_get_designated_lwkcpus</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_reserved_lwk_cpus</span> <span class="o">=</span> <span class="n">mos_get_reserved_lwk_cpus</span><span class="p">,</span>
        <span class="p">.</span><span class="n">request_lwk_cpus</span> <span class="o">=</span> <span class="n">mos_request_lwk_cpus</span><span class="p">,</span>
        <span class="p">.</span><span class="n">set_util_threads</span> <span class="o">=</span> <span class="n">mos_set_util_threads</span><span class="p">,</span>
        <span class="p">.</span><span class="n">map_cpu</span> <span class="o">=</span> <span class="n">mos_map_cpu</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_designated_lwkmem</span> <span class="o">=</span> <span class="n">mos_get_designated_lwkmem</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_reserved_lwkmem</span> <span class="o">=</span> <span class="n">mos_get_reserved_lwkmem</span><span class="p">,</span>
        <span class="p">.</span><span class="n">request_lwk_memory</span> <span class="o">=</span> <span class="n">mos_request_lwk_memory</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_numa_nodes_online</span> <span class="o">=</span> <span class="n">mos_get_numa_nodes_online</span><span class="p">,</span>
        <span class="p">.</span><span class="n">lock</span> <span class="o">=</span> <span class="n">mos_combo_lock</span><span class="p">,</span>
        <span class="p">.</span><span class="n">unlock</span> <span class="o">=</span> <span class="n">mos_combo_unlock</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_distance_map</span> <span class="o">=</span> <span class="n">mos_get_distance_map</span><span class="p">,</span>
        <span class="p">.</span><span class="n">lwkcpus_sequence_request</span> <span class="o">=</span> <span class="n">mos_lwkcpus_sequence_request</span><span class="p">,</span>
        <span class="p">.</span><span class="n">set_options</span> <span class="o">=</span> <span class="n">mos_set_options</span><span class="p">,</span>
        <span class="p">.</span><span class="n">set_lwkmem_mempolicy_info</span> <span class="o">=</span> <span class="n">mos_set_lwkmem_mempolicy_info</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_mos_view</span> <span class="o">=</span> <span class="n">mos_get_mos_view</span><span class="p">,</span>
        <span class="p">.</span><span class="n">set_mos_view</span> <span class="o">=</span> <span class="n">mos_set_mos_view</span><span class="p">,</span>
        <span class="p">.</span><span class="n">get_lwk_processes</span> <span class="o">=</span> <span class="n">mos_get_lwk_processes</span><span class="p">,</span>
<span class="p">};</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="rouge-code"><pre><span class="c1">//kernel/fork.c</span>
<span class="c1">//都是通过调用execvp直接继承设置的属性， 先通过提供的sys接口设置current task_struct里面的mos_process使用lwkcpu和lwkmem。lwk_mm_fork.</span>
<span class="n">dup_mmap</span>
    <span class="o">-&gt;</span><span class="n">lwkmem_fork</span>
    	<span class="o">-&gt;</span><span class="n">lwk_mm_fork</span>
 
 <span class="c1">//CLONE_THREAD 继承父进程的mos_process.</span>
<span class="k">static</span> <span class="n">__latent_entropy</span> <span class="k">struct</span> <span class="n">task_struct</span> <span class="o">*</span><span class="nf">copy_process</span><span class="p">(...</span>
<span class="p">{</span>
    <span class="p">...</span>
<span class="mi">2199</span><span class="o">:</span>  <span class="err">#</span><span class="n">ifdef</span> <span class="n">CONFIG_MOS_FOR_HPC</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">clone_flags</span> <span class="o">&amp;</span> <span class="n">CLONE_THREAD</span><span class="p">)</span> <span class="p">{</span>
                <span class="cm">/* A copy of an LWK thread is also an LWK thread. */</span>
                <span class="n">p</span><span class="o">-&gt;</span><span class="n">mos_flags</span> <span class="o">=</span> <span class="n">current</span><span class="o">-&gt;</span><span class="n">mos_flags</span><span class="p">;</span>
                <span class="n">p</span><span class="o">-&gt;</span><span class="n">mos_process</span> <span class="o">=</span> <span class="n">current</span><span class="o">-&gt;</span><span class="n">mos_process</span><span class="p">;</span>
                <span class="k">if</span> <span class="p">(</span><span class="n">current</span><span class="o">-&gt;</span><span class="n">mos_process</span><span class="p">)</span>
                        <span class="n">atomic_inc</span><span class="p">(</span><span class="o">&amp;</span><span class="n">current</span><span class="o">-&gt;</span><span class="n">mos_process</span><span class="o">-&gt;</span><span class="n">alive</span><span class="p">);</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                <span class="cm">/* A copy of an LWK process is not an LWK process. */</span>
                <span class="n">p</span><span class="o">-&gt;</span><span class="n">mos_flags</span> <span class="o">=</span> <span class="n">current</span><span class="o">-&gt;</span><span class="n">mos_flags</span> <span class="o">&amp;</span> <span class="o">~</span><span class="n">MOS_IS_LWK_PROCESS</span><span class="p">;</span>
                <span class="n">p</span><span class="o">-&gt;</span><span class="n">mos_process</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>

                <span class="cm">/* All Linux processes inherit the mOS view from its parent.
                 * The child process can override its view later by writing to
                 * its /proc/self/mos_view or by some other process writing to
                 * /proc/&lt;pid&gt;/mos_view
                 *
                 * This rule is not applicable to LWK processes. The child
                 * process starts off with the default view and does not in-
                 * -herit view from its parent LWK process.
                 *
                 * No need to lock child process since it is not yet active.
                 */</span>
                <span class="k">if</span> <span class="p">(</span><span class="n">is_mostask</span><span class="p">())</span>
                        <span class="n">SET_MOS_VIEW</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">MOS_VIEW_DEFAULT</span><span class="p">);</span>
        <span class="p">}</span>
<span class="cp">#endif   
</span>    <span class="p">...</span>
<span class="err">}</span>   
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="c1">//mOS/tools/yod/yod.c</span>
</pre></td></tr></tbody></table></code></div></div>

<h3 id="四lwkmem内存管理数据结构"><span class="me-2">四、lwkmem内存管理数据结构</span><a href="#四lwkmem内存管理数据结构" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<h3 id="五mpi-跨域通信"><span class="me-2">五、MPI 跨域通信</span><a href="#五mpi-跨域通信" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
</pre></td><td class="rouge-code"><pre><span class="nl">https:</span><span class="c1">//www.codenong.com/10542284/</span>
<span class="n">Open</span> <span class="n">MPI</span><span class="err">功能的方式是将其分为多个层，并且每个层的功能由动态加载的多个模块提供。有一种计分机制可以在特定条件下选择最佳模块。</span>
<span class="err">所有</span><span class="n">MPI</span><span class="err">实现都提供一种进行所谓</span><span class="n">SPMD</span><span class="err">启动的机制。本质上，</span><span class="n">MPI</span><span class="err">应用程序是</span><span class="n">SPMD</span><span class="p">(</span><span class="err">单程序多数据</span><span class="p">)</span><span class="err">的一种特殊类型</span><span class="o">-</span><span class="err">运行单个可执行文件的多个副本，并将消息传递用作通信和协调的机制。</span> <span class="n">SPMD</span><span class="err">启动器获取执行节点列表，远程启动流程并在它们之间建立关联和通信方案</span><span class="p">(</span><span class="err">在</span><span class="n">Open</span> <span class="n">MPI</span><span class="err">中，这称为</span><span class="n">MPI</span> <span class="n">Universe</span><span class="p">)</span><span class="err">。它是创建全局</span><span class="n">MPI</span><span class="err">通信器</span><span class="n">MPI_COMM_WORLD</span><span class="err">并分配初始等级分配的一种，它可以提供诸如将进程绑定到</span><span class="n">CPU</span><span class="err">内核的选项</span><span class="p">(</span><span class="err">在</span><span class="n">NUMA</span><span class="err">系统上非常重要</span><span class="p">)</span><span class="err">。一旦启动了进程，则可以使用某种识别机制</span><span class="p">(</span><span class="err">例如，等级与</span><span class="n">IP</span><span class="err">地址</span><span class="o">/</span> <span class="n">TCP</span><span class="err">端口之间的映射</span><span class="p">)</span><span class="err">，可以采用其他寻址方案。例如，开放式</span><span class="n">MPI</span><span class="err">使用</span><span class="n">ssh</span><span class="err">，</span><span class="n">rsh</span><span class="err">启动远程进程，也可以使用其他资源管理系统提供的机制</span><span class="p">(</span><span class="err">例如</span><span class="n">PBS</span> <span class="o">/</span> <span class="n">Torque</span><span class="err">，</span><span class="n">SLURM</span><span class="err">，</span><span class="n">Grid</span> <span class="n">Engine</span><span class="err">，</span><span class="n">LSF</span> <span class="p">...)</span><span class="err">。一旦进程启动并且它们的</span><span class="n">IP</span><span class="err">地址和端口号在</span><span class="n">Universe</span><span class="err">中记录和广播，进程就可以在其他</span><span class="p">(</span><span class="err">更快</span><span class="p">)</span><span class="err">网络上找到彼此，例如</span><span class="n">InfiniBand</span><span class="err">，并在它们之间建立通信路由。</span>
<span class="err">路由消息通常不是由</span><span class="n">MPI</span><span class="err">自己完成的，而是留给底层的通信网络。</span> <span class="n">MPI</span><span class="err">仅负责构造消息，然后将它们传递到网络以传递到目的地。对于驻留在同一节点上的进程之间的通信，通常使用共享内存。</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="问题一-hpc应用的特点-通信的主要用途是什么-关乎内存管理算法"><span class="me-2">问题一： HPC应用的特点？ 通信的主要用途是什么？ 关乎内存管理算法？</span><a href="#问题一-hpc应用的特点-通信的主要用途是什么-关乎内存管理算法" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<h4 id="问题二等待队列lwk域是否能使用"><span class="me-2">问题二：等待队列？lwk域是否能使用？</span><a href="#问题二等待队列lwk域是否能使用" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="rouge-code"><pre><span class="n">openMPI</span> <span class="n">mpirun</span><span class="err">四个线程：</span>
<span class="n">Thread</span> <span class="mi">1</span><span class="err">是主线程，在启动业务进程运行后，调用</span><span class="n">poll</span><span class="err">等待业务进程运行结束。业务进程结束后，</span><span class="n">Thread</span> <span class="mi">1</span><span class="err">完成清理工作退出。</span>
<span class="n">Thread</span> <span class="mi">2</span><span class="err">是</span><span class="n">progress</span> <span class="kr">thread</span><span class="err">，负责进程之间的异步通信，提供非阻塞的通信功能。线程启动后，会调用</span><span class="n">epoll_wait</span><span class="err">等待事件的到来。</span>
<span class="n">Thread</span> <span class="mi">3</span><span class="err">是本地连接监听线程，负责建立本地连接。线程启动后，调用</span><span class="n">select</span><span class="err">等待事件。</span>
<span class="n">Thread</span> <span class="mi">4</span><span class="err">是</span><span class="n">tcp</span><span class="err">监听线程，负责建立</span><span class="n">tcp</span><span class="err">连接。线程启动后，调用</span><span class="n">select</span><span class="err">等待事件。</span>

<span class="n">mpirun</span><span class="err">运行的后台线程是</span><span class="n">mpi</span><span class="err">进程间通信必不可少的，它们都有一个共同的特点，就是大部分时间都处于阻塞状态，没有在运行。这和</span><span class="n">lwk</span><span class="err">相性不佳，</span><span class="n">lwk</span><span class="err">上运行的线程是资源独占（</span><span class="n">CPU</span> <span class="o">+</span> <span class="err">内存）的，直到退出才会释放资源，如果</span><span class="n">mpirun</span><span class="err">的后台线程在</span><span class="n">lwk</span><span class="err">上运行，会造成计算资源的浪费。</span>
<span class="err">另外对于进程间的通信，同步通信在</span><span class="n">lwk</span><span class="err">域内就可以完成，但是异步通信需要跨域进行（需要和</span><span class="n">progress</span> <span class="kr">thread</span><span class="err">交互），从这点来看，“跨域”确实可能会对通信造成一定的影响。</span>
    
<span class="n">HPCG</span><span class="err">：高性能共轭梯度计算，超算性能的标准测试套。主要涉及</span> <span class="err">计算、访存、进程通信，一般要达到高性能，都需要针对</span><span class="n">CPU</span><span class="err">架构进行专门的优化，包括数据结构，代码流程，甚至是指令级别的优化。</span>
<span class="n">intel</span><span class="err">针对自己的</span><span class="n">CPU</span><span class="err">架构做了</span><span class="n">MPI</span> <span class="o">+</span> <span class="n">hpcg</span><span class="err">的优化，如果要在</span><span class="n">intel</span><span class="err">的</span><span class="n">CPU</span><span class="err">上达到高性能，需要使用</span><span class="n">intel</span> <span class="n">oneapi</span> <span class="o">+</span> <span class="n">intel</span> <span class="n">hpcg</span><span class="err">。</span>
    
<span class="err">目前来看，</span><span class="n">lwk</span><span class="err">和</span><span class="n">MPI</span><span class="err">进程通信的相性不是很好：在</span><span class="n">lwk</span><span class="err">上运行的线程，可能会被</span><span class="n">MPI</span><span class="err">进程通信阻塞，而当前线程占用的</span><span class="n">CPU</span><span class="err">资源是无法让给其他线程运行的，这就会造成</span><span class="n">CPU</span><span class="err">资源的浪费。</span>
<span class="err">这个问题有两个思路，一是使用</span><span class="n">MPI_Isend</span><span class="err">类似的接口，这是</span><span class="n">MPI</span><span class="err">提供的非阻塞调用，但是需要修改程序，兼容性很差；二是正面从架构上解决这个问题，目前</span><span class="n">mOS</span><span class="err">这种隔离运行的方式太过死板了（但应该是为了性能考虑），</span><span class="n">CPU</span><span class="err">资源其实是进程独占，而不是简单的</span><span class="n">lwk</span><span class="err">域独占，一旦进程被</span><span class="n">I</span><span class="o">/</span><span class="n">O</span><span class="err">阻塞，进程占有的整个</span><span class="n">CPU</span><span class="err">资源就都被浪费掉了。</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
</pre></td><td class="rouge-code"><pre><span class="n">crc</span><span class="err">计算卸载到计算域？</span>
<span class="err">那这个</span><span class="n">cpu</span><span class="err">预留就削减整体的性能了？</span>
    
<span class="err">如何快速的动态隔离出域？</span>
    <span class="mi">2</span><span class="err">个</span><span class="n">CPU</span><span class="err">处理一个</span><span class="n">ready</span><span class="err">队列，</span> <span class="mi">2</span><span class="err">个核进行抢锁，</span>
    <span class="n">https</span><span class="o">:</span><span class="c1">//cloud.tencent.com/developer/article/1517909 MuqSS调度器 有意思！！</span>
<span class="mi">2</span><span class="err">个</span><span class="n">cpu</span><span class="err">绑在一起，来并行两个调度类。</span>
<span class="n">cpu</span> <span class="n">active</span><span class="err">状态设置为其他状态，隔离起来？</span>
    <span class="mi">1</span><span class="p">)</span> <span class="err">局部的最优解</span>
    <span class="mi">2</span><span class="p">)</span> <span class="err">减小</span><span class="n">load</span> <span class="n">balance</span><span class="err">的锁粒度</span>
</pre></td></tr></tbody></table></code></div></div>


</div>

<div class="post-tail-wrapper text-muted">

  <!-- categories -->
  
  <div class="post-meta mb-3">
    <i class="far fa-folder-open fa-fw me-1"></i>
    
      <a href='/categories/linux/'>linux</a>,
      <a href='/categories/mos/'>mOS</a>
  </div>
  
  <!-- post.html -->

  <!-- tags -->
  
  <div class="post-tags">
    <i class="fa fa-tags fa-fw me-1"></i>
      
      <a href="/tags/mos/"
          class="post-tag no-text-decoration" >mOS</a>
      
  </div>
  
  
  <div class="post-tail-bottom
    d-flex justify-content-between align-items-center mt-3 pt-5 pb-2">
    <div class="license-wrapper">

      

        

        This post is licensed under 
        <a href="https://creativecommons.org/licenses/by/4.0/">
          CC BY 4.0
        </a>
         by the author.

      
    </div>

    <!-- Post sharing snippet -->

<div class="share-wrapper">
  <span class="share-label text-muted me-1">Share</span>
  <span class="share-icons">
    
    
    

    
      
      <a
        href="https://twitter.com/intent/tweet?text=High%20Performance%20OS%20-%20Intel%20HPC%20kernel%20mOS%20-%20Cheng%20Luo&url=https%3A%2F%2Fluochenglcs.github.io%2Fposts%2FIntel-HPC-mOS%2F"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        title="Twitter"
        target="_blank"
        rel="noopener"
        aria-label="Twitter"
      >
        <i class="fa-fw fab fa-twitter"></i>
      </a>
    
      
      <a
        href="https://www.facebook.com/sharer/sharer.php?title=High%20Performance%20OS%20-%20Intel%20HPC%20kernel%20mOS%20-%20Cheng%20Luo&u=https%3A%2F%2Fluochenglcs.github.io%2Fposts%2FIntel-HPC-mOS%2F"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        title="Facebook"
        target="_blank"
        rel="noopener"
        aria-label="Facebook"
      >
        <i class="fa-fw fab fa-facebook-square"></i>
      </a>
    
      
      <a
        href="https://t.me/share/url?url=https%3A%2F%2Fluochenglcs.github.io%2Fposts%2FIntel-HPC-mOS%2F&text=High%20Performance%20OS%20-%20Intel%20HPC%20kernel%20mOS%20-%20Cheng%20Luo"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        title="Telegram"
        target="_blank"
        rel="noopener"
        aria-label="Telegram"
      >
        <i class="fa-fw fab fa-telegram"></i>
      </a>
    

    <i
      id="copy-link"
      class="fa-fw fas fa-link small"
      data-bs-toggle="tooltip"
      data-bs-placement="top"
      title="Copy link"
      data-title-succeed="Link copied successfully!"
    >
    </i>
  </span>
</div>


  </div><!-- .post-tail-bottom -->

</div><!-- div.post-tail-wrapper -->


      
    
      
    </div>
  </div>
  <!-- #core-wrapper -->

  <!-- panel -->
  <div id="panel-wrapper" class="col-xl-3 ps-2 text-muted">
    <div class="access">
      <!-- Get the last 5 posts from lastmod list. -->














  <div id="access-lastmod" class="post">
    <div class="panel-heading">Recently Updated</div>
    <ul class="post-content list-unstyled ps-0 pb-1 ms-1 mt-2">
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/%E5%86%85%E5%AD%98%E6%95%B0%E6%8D%AE%E5%BA%93/">MMDB (memory database)</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/userspace-rcu%E9%94%81/">userspace rcu lock</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/Real-time-operating-system/">Realtime Operating System</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/HUNDSUN-LightOS/">Hundsun Lightos</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/linux-struct-folio/">struct folio</a>
        </li>
      
    </ul>
  </div>
  <!-- #access-lastmod -->


      <!-- The trending tags list -->















  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        



  <div id="access-tags">
    <div class="panel-heading">Trending Tags</div>
    <div class="d-flex flex-wrap mt-3 mb-1 me-3">
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/lock/">lock</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/libumem/">libumem</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/mm/">mm</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/autonuma/">autonuma</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bfs/">BFS</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bus/">Bus</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/caladan/">caladan</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/damon/">damon</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/deep-learning/">Deep Learning</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/dma/">DMA</a>
      
    </div>
  </div>


    </div>

    
      
      



  <div id="toc-wrapper" class="ps-0 pe-4 mb-5">
    <div class="panel-heading ps-3 pt-2 mb-2">Contents</div>
    <nav id="toc"><ul><li>High Performance OS - Intel HPC kernel mOS<ul><li><a href="#一-简介">一、 简介</a></li><li><a href="#二mos内存管理">二、mOS内存管理</a><ul><li><a href="#1lwkmem_partition_create创建lwkmem-partition">1、lwkmem_partition_create创建lwkmem partition</a><ul><li><a href="#1mos_mem_init初始化内存">1)mos_mem_init初始化内存</a></li></ul></li><li><a href="#2lwkmem_partition_destroy销毁lwkmem-partition">2、lwkmem_partition_destroy销毁lwkmem partition</a></li></ul></li><li><a href="#三how-use-yod">三、how use? yod</a><ul><li><a href="#问题2-syscall-cpu1utility_cpus-怎么使用处理syscall-什么意思">问题2： syscall cpu1/utility_cpus 怎么使用，处理syscall 什么意思？</a></li><li><a href="#问题3-lwkcpu的调度是个简化版具体原理">问题3： lwkcpu的调度是个简化版，具体原理？</a><ul><li><a href="#抓个lwkcpu的调度轨迹">抓个lwkcpu的调度轨迹？</a></li></ul></li><li><a href="#定论1lwkcpu只能一个program使用">定论1：lwkcpu只能一个program使用</a></li></ul></li><li><a href="#四lwkmem内存管理数据结构">四、lwkmem内存管理数据结构</a></li><li><a href="#五mpi-跨域通信">五、MPI 跨域通信</a><ul><li><a href="#问题一-hpc应用的特点-通信的主要用途是什么-关乎内存管理算法">问题一： HPC应用的特点？ 通信的主要用途是什么？ 关乎内存管理算法？</a></li><li><a href="#问题二等待队列lwk域是否能使用">问题二：等待队列？lwk域是否能使用？</a></li></ul></li></ul></li></ul></li></ul></nav>
  </div>
  


    
  </div>
</div>

<!-- tail -->

  <div class="row">
    <div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 px-3 pe-xl-4 mt-5">
      
        
        <!--
  Recommend the other 3 posts according to the tags and categories of the current post,
  if the number is not enough, use the other latest posts to supplement.
-->

<!-- The total size of related posts -->


<!-- An random integer that bigger than 0 -->


<!-- Equals to TAG_SCORE / {max_categories_hierarchy} -->








  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  
    
  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  






<!-- Fill with the other newlest posts -->





  <div id="related-posts" class="mb-2 mb-sm-4">
    <h3 class="pt-2 mb-4 ms-1" data-toc-skip>
      Further Reading
    </h3>
    <div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4 mb-4">
      
        
        
        <div class="col">
          <a href="/posts/linux-kcsan/" class="card post-preview h-100">
            <div class="card-body">
              <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class="small"
  data-ts="1599782400"
  data-df="ll"
  
>
  Sep 11, 2020
</em>

              <h4 class="pt-0 my-2" data-toc-skip>The Kernel Concurrency Sanitizer (KCSAN)</h4>
              <div class="text-muted small">
                <p>
                  





                  1 kcasan

2 使用

                </p>
              </div>
            </div>
          </a>
        </div>
      
        
        
        <div class="col">
          <a href="/posts/linux-kprobe/" class="card post-preview h-100">
            <div class="card-body">
              <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class="small"
  data-ts="1600041600"
  data-df="ll"
  
>
  Sep 14, 2020
</em>

              <h4 class="pt-0 my-2" data-toc-skip>Kernel Probe (kprobe)</h4>
              <div class="text-muted small">
                <p>
                  





                  1 kprobe

2 debugfs kprobe trace
kprobe trace 使用debugfs的trace功能
 p[:[GRP/]EVENT] [MOD:]SYM[+offs]|MEMADDR [FETCHARGS]  : Set a probe
 r[MAXACTIVE][:[GRP/]EVENT] [MOD:]SYM[+0] [FETCHARGS]  : Set a r...
                </p>
              </div>
            </div>
          </a>
        </div>
      
        
        
        <div class="col">
          <a href="/posts/linux-userfaultfd/" class="card post-preview h-100">
            <div class="card-body">
              <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class="small"
  data-ts="1600905600"
  data-df="ll"
  
>
  Sep 24, 2020
</em>

              <h4 class="pt-0 my-2" data-toc-skip>Kernel userfaultfd</h4>
              <div class="text-muted small">
                <p>
                  





                  Userfault只支持匿名页，hugetlb、共享内存；

一、软件流程

1 初始化
调用__NR_userfaultfd syscall初始化
调用syscall初始化建立匿名inode文件，并初始化file-&amp;gt;private_data,并返回用户态文件fd。


  
    用户态：

    uffd = syscall(__NR_userfaultfd, O_CLOEXE...
                </p>
              </div>
            </div>
          </a>
        </div>
      
    </div>
    <!-- .card-deck -->
  </div>
  <!-- #related-posts -->


      
        
        <!-- Navigation buttons at the bottom of the post. -->

<div class="post-navigation d-flex justify-content-between">
  
    <a
      href="/posts/Interesting-scheduler-BFS/"
      class="btn btn-outline-primary"
      prompt="Older"
    >
      <p>Interesting Kernel Scheduler - BFS</p>
    </a>
  

  
    <a
      href="/posts/High-Performance-OS-shanango/"
      class="btn btn-outline-primary"
      prompt="Newer"
    >
      <p>High Performance OS - shanango</p>
    </a>
  
</div>

      
        
        <!--  The comments switcher -->


      
    </div>
  </div>


        <!-- The Search results -->

<div id="search-result-wrapper" class="d-flex justify-content-center unloaded">
  <div class="col-11 post-content">
    <div id="search-hints">
      <!-- The trending tags list -->















  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        



  <div id="access-tags">
    <div class="panel-heading">Trending Tags</div>
    <div class="d-flex flex-wrap mt-3 mb-1 me-3">
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/lock/">lock</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/libumem/">libumem</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/mm/">mm</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/autonuma/">autonuma</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bfs/">BFS</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bus/">Bus</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/caladan/">caladan</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/damon/">damon</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/deep-learning/">Deep Learning</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/dma/">DMA</a>
      
    </div>
  </div>


    </div>
    <div id="search-results" class="d-flex flex-wrap justify-content-center text-muted mt-3"></div>
  </div>
</div>

      </div>
    </div>

    <!-- The Footer -->

<footer>
  <div class="container px-lg-4">
    <div class="d-flex justify-content-center align-items-center text-muted mx-md-3">
      <p>Using the <a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a> theme <a href="https://github.com/cotes2020/jekyll-theme-chirpy" target="_blank" rel="noopener">Chirpy</a>
      </p>

      <p>©
        2023
        <a href="https://gitee.com/luochenglcs">luochunsheng</a>.
        
          <span
            data-bs-toggle="tooltip"
            data-bs-placement="top"
            title="Except where otherwise noted, the blog posts on this site are licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) License by the author."
          >Some rights reserved.</span>
        
      </p>
    </div>
  </div>
</footer>


    <div id="mask"></div>

    <button id="back-to-top" aria-label="back-to-top" class="btn btn-lg btn-box-shadow">
      <i class="fas fa-angle-up"></i>
    </button>

    
      <div
        id="notification"
        class="toast"
        role="alert"
        aria-live="assertive"
        aria-atomic="true"
        data-bs-animation="true"
        data-bs-autohide="false"
      >
        <div class="toast-header">
          <button
            type="button"
            class="btn-close ms-auto"
            data-bs-dismiss="toast"
            aria-label="Close"
          ></button>
        </div>
        <div class="toast-body text-center pt-0">
          <p class="px-2 mb-3">A new version of content is available.</p>
          <button type="button" class="btn btn-primary" aria-label="Update">
            Update
          </button>
        </div>
      </div>
    

    <!-- JS selector for site. -->

<!-- commons -->



<!-- layout specified -->


  

  
    <!-- image lazy-loading & popup & clipboard -->
    
  















  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  



  <script src="https://cdn.jsdelivr.net/combine/npm/jquery@3.7.0/dist/jquery.min.js,npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js,npm/simple-jekyll-search@1.10.0/dest/simple-jekyll-search.min.js,npm/lazysizes@5.3.2/lazysizes.min.js,npm/magnific-popup@1.1.0/dist/jquery.magnific-popup.min.js,npm/clipboard@2.0.11/dist/clipboard.min.js,npm/dayjs@1.11.7/dayjs.min.js,npm/dayjs@1.11.7/locale/en.min.js,npm/dayjs@1.11.7/plugin/relativeTime.min.js,npm/dayjs@1.11.7/plugin/localizedFormat.min.js,npm/tocbot@4.21.0/dist/tocbot.min.js"></script>






<script defer src="/assets/js/dist/post.min.js"></script>






    

    <!--
  Jekyll Simple Search loader
  See: <https://github.com/christian-fei/Simple-Jekyll-Search>
-->





<script>
  /* Note: dependent library will be loaded in `js-selector.html` */
  SimpleJekyllSearch({
    searchInput: document.getElementById('search-input'),
    resultsContainer: document.getElementById('search-results'),
    json: '/assets/js/data/search.json',
    searchResultTemplate: '<div class="px-1 px-sm-2 px-lg-4 px-xl-0">  <a href="{url}">{title}</a>  <div class="post-meta d-flex flex-column flex-sm-row text-muted mt-1 mb-1">    {categories}    {tags}  </div>  <p>{snippet}</p></div>',
    noResultsText: '<p class="mt-5"></p>',
    templateMiddleware: function(prop, value, template) {
      if (prop === 'categories') {
        if (value === '') {
          return `${value}`;
        } else {
          return `<div class="me-sm-4"><i class="far fa-folder fa-fw"></i>${value}</div>`;
        }
      }

      if (prop === 'tags') {
        if (value === '') {
          return `${value}`;
        } else {
          return `<div><i class="fa fa-tag fa-fw"></i>${value}</div>`;
        }
      }
    }
  });
</script>

  </body>
</html>

